package cn.tomas.rabbit.direct.listener;

import cn.tomas.rabbit.dto.UserDTO;
import com.alibaba.fastjson.JSONObject;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @author Mr.Still
 * @version 1.0.0
 * @date 2021-11-11 10:42
 **/
@Component
public class DirectListener {

    @RabbitListener(queues = "direct.error.queue")
    public void weChatFanoutListener(String msg) throws Exception {
        UserDTO o = JSONObject.parseObject(msg, UserDTO.class);
        System.out.println(JSONObject.toJSONString(o) + "------ WeChat" + new Date().toString());
    }

    @RabbitListener(queues = "direct.info.queue")
    public void smsFanoutListener(String msg) throws Exception {
        UserDTO o = JSONObject.parseObject(msg, UserDTO.class);
        System.out.println(JSONObject.toJSONString(o) + "------ sms" + new Date().toString());
    }
}
